<?php
/**
 * @package		Joomla.Administrator
 * @copyright	Copyright (C) 2005 - 2013 Open Source Matters, Inc. All rights reserved.
 * @license		GNU General Public License version 2 or later; see LICENSE.txt
 */
// Set flag that this is a parent file
define('_JEXEC', 1);
define('DS', DIRECTORY_SEPARATOR);

// set timeout session
ini_set('session.gc-maxlifetime', 60*30);


if (file_exists(dirname(__FILE__) . '/defines.php')) {
	include_once dirname(__FILE__) . '/defines.php';
}

if (!defined('_JDEFINES')) {
	define('JPATH_BASE', dirname(__FILE__));
	require_once JPATH_BASE.'/includes/defines.php';
}

require_once JPATH_BASE.'/includes/framework.php';
require_once JPATH_BASE.'/includes/helper.php';
require_once JPATH_BASE.'/includes/toolbar.php';

//include 'dump.php';

// Mark afterLoad in the profiler.
JDEBUG ? $_PROFILER->mark('afterLoad') : null;

// Instantiate the application.
$app = JFactory::getApplication('administrator');

// load librarie B&G
include JPATH_BASE.'/includes/bgHelper.php';
include JPATH_BASE.'/includes/bgHelpertop.php';
include JPATH_BASE.'/includes/bgAuthorize.php';
include JPATH_BASE."/includes/bgData.php";
include JPATH_BASE."/includes/zipSearch.php";

// Initialise the application.
$app->initialise(array(
	'language' => $app->getUserState('application.lang')
));

// Mark afterIntialise in the profiler.
JDEBUG ? $_PROFILER->mark('afterInitialise') : null;

// Route the application.
$app->route();

include 'ga.php';
/*$document->addScriptDeclaration("
	(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
	(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
	m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
	})(window,document,'script','//www.google-analytics.com/analytics.js','ga');

	ga('create', 'UA-20000176-2', 'bgf.or.jp');
	ga('send', 'pageview');
");*/




// Mark afterRoute in the profiler.
JDEBUG ? $_PROFILER->mark('afterRoute') : null;

// Dispatch the application.
$app->dispatch();

// Mark afterDispatch in the profiler.
JDEBUG ? $_PROFILER->mark('afterDispatch') : null;

// Render the application.
$app->render();

// Mark afterRender in the profiler.
JDEBUG ? $_PROFILER->mark('afterRender') : null;

// Return the response.
echo $app;


/*********************/

/*$auth = new bgAuthorize();
if(JRequest::getVar('option') == 'com_cpanel'){
    $_SERVER['REQUEST_URI'] = 'index.php?option=com_cpanel';
}
$button = '(<a href="#">Current : '.$auth->getUserGroup().'</a>) - ';
$button .= '<a href="'.$_SERVER['REQUEST_URI'].'&usertype=8">User 8</a> - ';						
$button .= '<a href="'.$_SERVER['REQUEST_URI'].'&usertype=9">User 9</a> - ';			
$button .= '<a href="'.$_SERVER['REQUEST_URI'].'&usertype=10">User 10</a> - ';			
$button .= '<a href="'.$_SERVER['REQUEST_URI'].'&usertype=11">User 11</a> - ';			
$button .= '<a href="'.$_SERVER['REQUEST_URI'].'&usertype=12">User 12</a>';			
$button .= ' *** <a href="index.php?option=com_installer">Installer</a>';
$button .= ' *** <a href="index.php?m=f">Show menu</a>';			
echo $button;*/
/****************************/